#include "Player.hpp"
#include "Opcode.hpp"
#include "CSProto.hpp"
#include <functional>
#include "Singleton.hpp"
#include "cs.pb.h"
#include "test.pb.h"
#include "RoomMgr.hpp"
Player::Player(std::shared_ptr<WorldSession> session) : _session(session)
{

}

Player::~Player()
{

}

bool Player::RegisterProtocol()
{
    RegisterProtoHandler(CS_PROTO::CS_PROTO_LOGIN, example::Person, &Player::Login)
    RegisterProtoHandler(CS_PROTO::CS_PROTO_CREATE_ROOM, cs::CreateRoomReq, &Player::RecvCreateRoomMsg)
    return true;
}

bool Player::Update(uint32_t diff)
{
    // ...
    return _session->Update(diff);
}

std::shared_ptr<WorldSession>& Player::GetSession()
{
    return _session;
}

void Player::RecvCreateRoomMsg(const cs::CreateRoomReq& msg)
{
    Singleton<RoomMgr>::getInstance()->PlayerCreateRoom(shared_from_this(), msg);
}